<template>
  <div>
    <s-table
      ref="table"
      size="default"
      :columns="columns"
      :data="loadData"
      showPagination="auto"
      :rowKey="(record) => record.id"
      :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
    >
    </s-table>
  </div>
</template>
<script>
import { STable } from '@/components'
import { getAntPermissions } from '@/api/permission'
const statusMap = {
  1: {
    types: '1',
    text: 'error'
  },
  2: {
    types: '2',
    text: 'success'
  }
}

const columns = [
      {
        title: '资源编码',
        dataIndex: 'action'
      },
      {
        title: '资源类型',
        dataIndex: 'types',
        scopedSlots: { customRender: 'types' }
      },
      {
        title: '资源名称',
        dataIndex: 'des'
      }
    ]
export default {
  name: 'User',
  components: {
    STable
  },
  data () {
    return {
      formInline: {
        action: '',
        types: '',
        des: ''
      },
      columns,
      selectedRowKeys: [],
      selectedRows: [],
      upmsUserRoleDepPageRequest: { menuId: 1 },
      loadData: parameter => {
        return getAntPermissions(this.upmsUserRoleDepPageRequest).then(res => {
            console.log('getUserList', res)
            return res.result
          })
      }
    }
  },
  filters: {
    statusFilter (type) {
      const s = statusMap[type].text
      console.log('statusFilter' + s)
      return s
    },
    statusTypeFilter (type) {
      const s = statusMap[type].types
      console.log('statusTypeFilter' + s)
      return s
    }
  },
  mounted () {
    // this.featch()
  },
  methods: {
    onSelectChange (selectedRowKeys, selectedRows) {
      debugger
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    },
    featch () {
      // const th = this
      // th.$refs.table.refresh()
      debugger
      this.$nextTick(() => {
        this.loadData = getAntPermissions(this.upmsUserRoleDepPageRequest).then(res => {
          debugger
          return res.result
        })
        this.$refs.table.refresh(true)
      })
    }
  }
}
</script>
<style scoped>
.editable-row-operations a {
  margin-right: 8px;
}
</style>
